<?php
/**
 * Created by PhpStorm.
 * User: 夏浩文
 * Date: 2017-06-29
 * Time: 上午11:27
 * Versions：v1.00
 */

namespace app\hongyanche\controller;


class Cart
{
    //加入购物车
    public function add_cart()
    {
        $detail_id = input('detail_id');
//        $num = input('amount');
        $res = model('cart')->add('mall',$detail_id);
        return json($res);
    }
    //获取购物车列表
    public function getlist(){
        $filter['page'] = input('page');
        $filter['maxPerPage'] = input('maxPerPage');
        $filter['keywords'] = input('keywords');
        $filter['demand'] = 'mall';
        $res = model('cart')->getList($filter);
        return json($res);
    }
    //修改购物车数量
    public function modify()
    {
        $detail_id = input("deatil_id");
        $amount = input("amount");
        $res = model('cart')->setNum($detail_id,$amount);
        return json($res);
    }

    //清空购物车
    public function remove()
    {
        $detail_id = input("detail_id");
        $res = model('cart')->remove($detail_id);
        return json($res);
    }

    public function amount()
    {
        $res = model('cart')->amount();
        return json($res);
    }
}